package org.geektimes.projects.user.management;

import org.apache.commons.lang.StringUtils;

import java.io.IOException;

/**
 @author :   chuan
 @date :   2021/03/17
 */
public class HomeworkManager implements HomeworkManagerMBean {

    private final static String DEFAULT_WEBSITE_URL = "https://time.geekbang.org/";

    private String visitUrl;

    @Override
    public String getName() {
        return "homework:week03:mbean";
    }

    @Override
    public String getVisitUrl() {
        return StringUtils.isNotBlank(this.visitUrl) ? this.visitUrl : DEFAULT_WEBSITE_URL;
    }

    @Override
    public void setVisitUrl(String visitUrl) {
        this.visitUrl = visitUrl;
    }

    @Override
    public void gotoVisitSite() throws IOException {
        Runtime.getRuntime().exec("cmd /c start " + getVisitUrl());
    }
}
